package lesson5;

public class task9 {

		public static void main(String[] args) {
			
			int[][] array = {
					{1,4,3,6},
					{7,5,9,2},
					{3,3,5,11},
					{6,9,9,1}
			};
			int maxSum = 0;
			int maxRowIdx = 0;
			int maxColIdx = 0;
			
			for(int i = 0; i < array.length-1; i++)
			{
				for(int j = 0; j < array[i].length-1; j++)
				{
					int sum = array[i][j]+array[i][j+1]+array[i+1][j]+array[i+1][j+1];
					if(maxSum < sum)
					{
						maxSum = sum;
						maxRowIdx = i;
						maxColIdx = j;
					}
				}
			}
			
			System.out.println("Max sum is = " + maxSum);
			System.out.println("Winner is:");
			System.out.print(array[maxRowIdx][maxColIdx] + " ");
			System.out.print(array[maxRowIdx][maxColIdx+1] + " ");
			System.out.println();
			System.out.print(array[maxRowIdx+1][maxColIdx] + " ");
			System.out.print(array[maxRowIdx+1][maxColIdx+1] + " ");
		}
}
